package com.xhwl.centiotdata.pushtrigger.alarm;

import com.alibaba.fastjson.JSONObject;
import com.xhwl.centiotdata.handler.alarm.impl.AlarmHuaWeiIotDAAccessInformationHandler;
import com.xhwl.common.pojo.ResultJson;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Leon
 * @Description: TODO
 * @Date: 2022/4/26 9:56
 */
@RestController
@RequestMapping("/")
@Slf4j
public class HuaweiIotAlarmController {

    @Autowired
    AlarmHuaWeiIotDAAccessInformationHandler alarmHuaWeiIotDAAccessInformationHandler;

    @PostMapping("/alarm-receive/huaweiiot-receive")
    public ResultJson huaweiIotAlarmReceive(@RequestBody String receive){
        log.info("IOTDA推送海康告警原始数据为==========>{}", JSONObject.toJSONString(receive));
        alarmHuaWeiIotDAAccessInformationHandler.execute(receive);
        return ResultJson.success();
    }
}
